﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NeuralNetworkComponents
{
    public abstract class Network
    {
        public Int32 InputsCount { get; protected set; }
        public Int32 LayersCount { get; protected set; }
        public Layer[] Layers { get; protected set; }
        public Double[] Output { get; protected set; }

        public Layer this[int index]
        {
            get { return Layers[index]; }
        }

        protected Network(int inputsCount, int layersCount)
        {
            this.InputsCount = Math.Max(1, inputsCount);
            this.LayersCount = Math.Max(1, layersCount);

            Layers = new Layer[this.LayersCount];
        }

        public virtual Double[] Compute(Double[] input)
        {
            Output = input;
            foreach (Layer layer in Layers)
            {
                Output = layer.Compute(Output);
            }

            return Output;
        }

        public virtual void Randomize()
        {
            foreach (Layer layer in Layers)
            {
                layer.Randomize();
            }
        }
    }
}
